# -*- coding: utf-8 -*-
import socket

# 目标地址IP/URL及端口
target_host = "127.0.0.1"
target_port = 9999
bufs = 1024
# 创建一个socket对象
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 连接主机
client.connect((target_host, target_port))

# # 发送数据
# client.send("abc".encode('utf8'))
# # 接收响应
# response = client.recv(4096)
# print(response)
while True:
    data = input(">")
    if not data:
        break
    client.send(data.encode('utf8'))
    data =client.recv(bufs).decode('utf8')
    if not data:
        break
    print('收到服务端数据->',data)
client.close()